package com.apestech.api.condition.Step;

import com.apestech.api.condition.ConditionExec;
import com.apestech.framework.json.JSONObject;
import com.apestech.framework.xml.condition.modul.ConditionStrategy;

public class StepCondition extends StepPubField {

    private ConditionExec condition;

    public StepCondition(ConditionStrategy.Step step, ConditionExec condition) throws Exception {
        super(step, condition.getCondition().getSession());
        this.condition=condition;
        condition.setIsbreak(step.isIsbreak());
        step.setMustInput(condition.getDimensionField().getKeyStr());
        super.setInput(null);
        super.setResultMap(null);
    }

    @Override
    public void exec() throws Exception {
        super.getStep().setResultMap(null);
        JSONObject o=condition.getCondition(super.getInput());
        boolean flag="1".equals(o.get("sys_break"));
        finiExec(o, super.getStep());
        if(!flag){
            super.getStep().setResultMap(o);
            //super.setResultMap(o);
        }
    }

    @Override
    public String showMinInput() throws Exception {
        return condition.getMinInput();
    }

    public ConditionExec getCondition() {
        return condition;
    }
}
